<!DOCTYPE html>
<html>
<head>
  <meta charset="UTF-8">
  <title>Document</title>
  <style>
    
  </style>
</head>
<body>
  <input type="text" id="txt" disabled>
  <input type="button" id="btn" value="点名">
</body>
<script>

  var txt = document.getElementById("txt");
  var btn = document.getElementById("btn");

  // 名字库
  var names = ["张三", "李四", "王二", "赵五", "钱六", "李七", "周八"];

  btn.onclick = function(){
    // 根据数组的索引范围，取随机数
    var n = random(0, names.length-1);
    // 将取出的随机数作为索引，读取数组中的数据
    txt.value = names[n];
  }
  
  // 范围随机数
  function random(max,min){
    return Math.round( Math.random() * (max-min) + min );
  }

</script>
</html>